﻿using System.Collections.Generic;
using Preactor.ObjectModel.Interfaces;

namespace Preactor.ObjectModel.Utilities
{
    public static class PreactorObjectModelExtensions
    {
        public static IOperation GetOperation(this PreactorObjectModel preactorObjectModel, int recordNumber)
        {
            return preactorObjectModel.GetRecord<IOperation>(recordNumber);
        }

        public static IOperation GetOperation(this PreactorObjectModel preactorObjectModel, PrimaryKey pk)
        {
            return preactorObjectModel.GetRecord<IOperation>(pk);
        }

        public static IEnumerable<IOperation> GetAllOperations(this PreactorObjectModel preactorObjectModel)
        {
            return preactorObjectModel.GetAllRecords<IOperation>();
        }

        public static IEnumerable<IResource> GetAllResources(this PreactorObjectModel preactorObjectModel)
        {
            return preactorObjectModel.GetAllRecords<IResource>();
        }

        public static IEnumerable<IResourceGroup<IResource>> GetAllResourceGroups(this PreactorObjectModel preactorObjectModel)
        {
            return preactorObjectModel.GetAllRecords<IResourceGroup<IResource>>();
        }

        public static IResource GetResourceByName(this PreactorObjectModel preactorObjectModel, string name)
        {
            return preactorObjectModel.GetRecordByName<IResource>(name);
        }

        public static IResourceGroup<IResource> GetResourceGroupByName(this PreactorObjectModel preactorObjectModel, string name)
        {
            return preactorObjectModel.GetRecordByName<IResourceGroup<IResource>>(name);
        }

        public static IEnumerable<ISecondaryConstraint> GetAllSecondaryConstraints(this PreactorObjectModel preactorObjectModel)
        {
            return preactorObjectModel.GetAllRecords<ISecondaryConstraint>();
        }

        public static ISecondaryConstraint GetSecondaryConstraintByName(this PreactorObjectModel preactorObjectModel, string name)
        {
            return preactorObjectModel.GetRecordByName<ISecondaryConstraint>(name);
        }
    }
}
